package cn.edu.xmu.experiment.PulseComms.controller;

import cn.edu.xmu.experiment.PulseComms.Service.GroupService;
import cn.edu.xmu.experiment.PulseComms.Service.MessageService;
import cn.edu.xmu.experiment.PulseComms.entity.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/groups")
public class GroupController {

    @Autowired
    private GroupService groupService;


    @PostMapping("/{groupName}/join")
    public boolean joinGroup(@PathVariable String groupName, @RequestParam String username) {
        return groupService.joinGroup(groupName, username);
    }

    @PostMapping("/{groupName}/send")
    public boolean sendGroupMessage(@PathVariable String groupName, @RequestParam String username, @RequestBody Message message) {
        return groupService.sendGroupMessage(groupName, username, message);
    }



}